﻿var MAD = {};
MAD.core = (function() {
    var _cardImgs = {
        delta: "url(/common/images/checkout/delta.gif) no-repeat",
        electron: "url(/common/images/checkout/electron.gif) no-repeat",
        maestro: "url(/common/images/checkout/maestro.gif) no-repeat",
        mastercard: "url(/common/images/checkout/mastercard.gif) no-repeat",
        solo: "url(/common/images/checkout/solo.gif) no-repeat",
        visa: "url(/common/images/checkout/visa.gif) no-repeat",
        amex: "url(/common/images/checkout/amex.gif) no-repeat"
    };
    var _changeCard = function(e, args) {
        var selectEl = (args.id != null) ? document.getElementById(args.id) : null;
        var imgEl = (args.imgId != null) ? document.getElementById(args.imgId) : null;
        var cardIndex = selectEl.selectedIndex;
        var cardChoice = selectEl[cardIndex].text.toLowerCase(); (cardIndex == 0) ? imgEl.style.background = "none": null;
        var imgPath = _cardImgs[cardChoice];
        imgEl.style.background = imgPath
    };
    var _bookmark = function(title, url) {
        if (window.sidebar) {
            window.sidebar.addPanel(title, url, "")
        } else {
            if (document.all) {
                window.external.AddFavorite(url, title)
            } else {
                if (window.opera && window.print) {
                    return true
                }
            }
        }
    };
    var _closeAddress = function() {
        $(this).parent().find(".genericAddress").slideUp(700);
        $(".slideParentSame").children("div").addClass("existingOn").removeClass("existingOff");
        $(".slideParentDiff").children("div").addClass("existingOff").removeClass("existingOn")
    };
    var _openAddress = function() {
        $(this).parent().find(".genericAddress").slideDown(700);
        $(".slideParentSame").children("div").addClass("existingOff").removeClass("existingOn");
        $(".slideParentDiff").children("div").addClass("existingOn").removeClass("existingOff")
    };
    return {
        changeCard: _changeCard,
        bookmark: _bookmark
    }
})();
MAD.lightBox = (function() {
    var _init = function() {
        $(".overlay").click(function() {
            if (!$(".modal").is(":visible")) {
                $(".lightbox").hide();
                $(".expandedContent").hide();
                $(this).hide()
            }
        });
        $(".lightbox .btn_close").attr("href", "javascript:MAD.lightBox.hide();")
    };
    var _show = function(id) {
        $(id).css("top", ($(window).height() - $(id).height()) / 2 + $(window).scrollTop() + "px");
        $(id).css("left", ($(window).width() - $(id).width()) / 2 + $(window).scrollLeft() + "px");
        $(".overlay").show();
        $(id).show();
        return false
    };
    var _hide = function() {
        $(".lightbox").hide();
        $(".overlay").hide()
    };
    return {
        init: _init,
        show: _show,
        hide: _hide
    }
})();
MAD.treepodia = (function() {
    var _acc;
    var _accID;
    var _skus = [];
    var _vids;
    var _product;
    var _init = function(account) {
        _accID = account;
        _getAccount()
    };
    var _getAccount = function() {
        if (_acc === undefined) {
            _acc = Treepodia.getAccount(_accID)
        }
    };
    var _showLB = function(Video, title, prodURL) {
        MAD.lightBox.show(".lbTreepodia");
        _getProductVideo(Video,
        function(videoController) {
            videoController.setAutoplay(true);
            videoController.setWidth(554);
            videoController.setHeight(351);
            videoController.setWmode("transparent");
            videoController.show("swfDiv")
        });
        $(".lbTreepodia").find("h3").html(title);
        if (prodURL.length > 0) {
            $(".lbTreepodia").find("a.btn_viewProductLarge").css("display", "block");
            $(".lbTreepodia").find("a.btn_viewProductLarge").attr("href", prodURL)
        } else {
            $(".lbTreepodia").find("a.btn_viewProductLarge").css("display", "none");
            $(".lbTreepodia").find("a.btn_viewProductLarge").attr("href", "")
        }
        $(".lbTreepodia a.btn_close").click(function() {
            MAD.treepodia.stopVideo(Video)
        });
        $(".overlay").click(function() {
            if (!$(".modal").is(":visible")) {
                $(".lightbox").hide();
                $(".expandedContent").hide();
                $(this).hide()
            }
            MAD.treepodia.stopVideo(Video);
            $(".overlay").click(function() {
                if (!$(".modal").is(":visible")) {
                    $(".lightbox").hide();
                    $(".expandedContent").hide();
                    $(this).hide()
                }
            })
        })
    };
    var _stopVideo = function(Video) {
        _getProductVideo(Video,
        function(vc) {
            vc.setAutoplay(false);
            vc.setWidth(554);
            vc.setHeight(351);
            vc.setWmode("transparent");
            vc.show("swfDiv")
        })
    };
    var _playVideo = function(Video, title) {
        _showLB(Video, title, "")
    };
    var _getProduct = function(sku) {
        _product = Treepodia.getProduct(_accID, sku)
    };
    var _getProductVideo = function(sku, handler) {
        _getProduct(sku);
        _product.requestVideo(handler)
    };
    var _logAddBasket = function(sku) {
        if (_product === undefined) {
            _getProduct(sku)
        }
        _product.logAddToCart()
    };
    return {
        init: _init,
        playVideo: _playVideo,
        showLB: _showLB,
        stopVideo: _stopVideo,
        logAddBasket: _logAddBasket,
        getProductVideo: _getProductVideo
    }
})();
MAD.products = (function() {
    var _Products = [];
    var _addProduct = function(o) {
        _Products[o.id] = o
    };
    var _findProduct = function(i) {
        return _Products[i]
    };
    function enlargeProduct(i) {
        var enProd = i;
        $(".lbEnlargeProduct").find("img").attr("src", "");
        $(".lbEnlargeProduct").find("h3").html(enProd.brandName + " " + enProd.name);
        $(".lbEnlargeProduct").find(".commMsg").html(enProd.commercialMsg);
        $(".lbEnlargeProduct").find("img").attr("src", enProd.image);
        $(".lbEnlargeProduct").find("a.btn_viewProdDetails").attr("href", enProd.href);
        $(".lbEnlargeProduct").click(function() {
            MAD.lightBox.hide()
        });
        showLightBox(".lbEnlargeProduct")
    }
    var _showProduct = function(target, sender, i) {
        var link = $(sender).find("h3 a").attr("href");
        target = "#" + target;
        var aTitle = $(target + "_aTitle");
        aTitle.attr("href", link);
        $(target + "_aView").attr("href", link);
        $(target + "_imgProduct").parents("a").attr("href", link);
        var img = $(target + "_imgProduct");
        img.attr("src", $(sender).find("img").attr("src"));
        img.attr("width", $(sender).find("img").attr("width"));
        img.attr("height", $(sender).find("img").attr("height"));
        var o = _findProduct(i);
        $(".magnify").click(function() {
            enlargeProduct(o);
            return false
        });
        aTitle.html("<strong>" + o.brandName + "</strong> " + o.name);
        aTitle.title = o.brandName + " " + o.name;
        if ($(sender).find(".image span").attr("class")) {
            $(target + "_Sash").attr("class", $(sender).find(".image span").attr("class"))
        } else {
            $(target + "_Sash").attr("class", "")
        }
        if ($(sender).find(".image span").css("background-image")) {
            $(target + "_Sash").css("background-image", $(sender).find(".image span").css("background-image"))
        } else {
            $(target + "_Sash").css("background-image", "")
        }
        $(target).find(".specialTag").remove();
        $(target).find(".newTag").remove();
        if ($(sender).find(".specialTag").attr("class")) {
            $(target).append('<div class="specialTag"></div>')
        }
        if ($(sender).find(".newTag").attr("class")) {
            $(target).append('<div class="newTag"></div>')
        }
        $(target + "_CommMsg").html(o.commercialMsg);
        if (o.price == "HIDE") {
            $(target + "_Price").html('<a href="' + o.href + '" title="Click for price">Click for price</a>');
            $(target + "_Save").html("");
            $(target + "_RRP").html("")
        } else {
            if (o.price == "titleist") {
                $(target + "_Price").html('<a href="#"><strong></strong></a>');
                $(target + "_Save").html("");
                $(target + "_RRP").html("")
            } else {
                $(target + "_Price").html("PRICE <strong>&pound;" + o.price + "</strong>");
                if (o.save > 0) {
                    $(target + "_Save").html("SAVE <span>" + o.save + "%</span>");
                    $(target + "_RRP").html("MRRP &pound;" + o.rrp)
                } else {
                    $(target + "_Save").html("");
                    $(target + "_RRP").html("")
                }
            }
        }
        var aVideo = $(target + "_aVideo");
        if (! (o.video == "NOVID")) {
            aVideo.attr("href", "javascript:MAD.treepodia.showLB('" + o.video + "','" + o.brandName + " " + o.name + "','" + o.href + "');");
            aVideo.css({
                display: "block"
            })
        } else {
            aVideo.css({
                display: "none"
            })
        }
        var divDeal = $(target + "_Deal");
        if (o.discount) {
            if (o.discount.type == "GIFT") {
                if (o.discount.value == "100") {
                    divDeal.html('<strong>FREE <a href="' + o.discount.href + '" title="' + o.discount.name + '">' + o.discount.name + "</a></strong><br/>Value &pound;" + o.discount.price)
                } else {
                    divDeal.html("<strong>" + o.discount.value + '% OFF <a href="' + o.discount.href + '" title="' + o.discount.name + '">' + o.discount.name + "</a></strong><br/>Value &pound;" + o.discount.price + " Save &pound;" + o.discount.save)
                }
            } else {
                if (o.discount.type == "MULTI") {
                    if (o.price == "HIDE") {
                        divDeal.html('<strong>MULTIBUY <a href="' + o.discount.href + '" title="MULTIBUY Click for price">Click for price</a></strong>')
                    } else {
                        if (o.price == "titleist") {
                            divDeal.html("<strong>MULTIBUY Available</strong>")
                        } else {
                            divDeal.html('<strong>MULTIBUY <a href="' + o.discount.href + '" title="MULTIBUY Buy ' + o.discount.value + " for &pound;" + o.discount.price + '">Buy ' + o.discount.value + " for &pound;" + o.discount.price + "</a></strong>")
                        }
                    }
                }
            }
            divDeal.css({
                display: "block"
            })
        } else {
            divDeal.html("");
            divDeal.css({
                display: "none"
            })
        }
        var divRating = $(target + "_Rating");
        var divOOS = $(target + "_OOS");
        if (o.oos <= 0) {
            divRating.removeClass("norating");
            divRating.removeClass("rating");
            divRating.addClass("stockWarning");
            divRating.html("Out of Stock")
        } else {
            if (o.rating > 0) {
                divRating.removeClass("norating");
                divRating.removeClass("rating");
                divRating.removeClass("stockWarning");
                divRating.addClass("rating");
                divRating.html('<div class="count" style="width:' + o.rating + 'px;"></div>')
            } else {
                divRating.removeClass("norating");
                divRating.removeClass("rating");
                divRating.removeClass("stockWarning");
                divRating.addClass("norating");
                divRating.html("<!-- -->")
            }
        }
    };
    var slightDelay;
    var dynamicClass;
    var objTopPad;
    var top;
    var left;
    var _attachProductHover = function() {
        $(".withHover").hoverIntent({
            sensitivity: 3,
            interval: 200,
            timeout: 0,
            over: function() {
                dynamicClass = ($(this).parents("div").attr("class") + "Hover");
                var pos = $(this).offset();
                left = pos.left;
                top = pos.top;
                objTopPad = parseInt($(this).css("padding-top"));
                left -= 18;
                top -= (38 - objTopPad);
                if ($(this).hasClass("divide") && $(this).parents("div").hasClass("subCatGrid")) {
                    left = left + 11
                }
                if ($(this).hasClass("divide") && $(this).parents("div").hasClass("subCatGrid") && $(this).parents("div").hasClass("nike")) {
                    left = left - 11
                }
                if ($(this).hasClass("divide") && $(this).parents("div").hasClass("subCatGrid") && $(this).parents("div").hasClass("taylormade")) {
                    left = left - 10
                }
                if ($(this).hasClass("divide") && $(this).parents("div").hasClass("subCatGrid") && $(this).parents("div").hasClass("cobra")) {
                    left = left - 11
                }
                $(".productPopupContainer").css({
                    left: left,
                    top: top
                });
                var proddiv = $(this);
                MAD.products.showProduct(enlargeContID, proddiv, proddiv.attr("prod"));
                $(".productPopupContainer").mouseover()
            },
            out: function() {}
        })
    };
    var _productPopupHover = function() {
        $(".productPopupContainer").hover(function(event) {
            $(".productPopup").addClass(dynamicClass);
            $(".productPopupContainer").show()
        },
        function() {
            $(".productPopup").removeClass(dynamicClass);
            $(".productPopupContainer").hide()
        })
    };
    return {
        addProduct: _addProduct,
        findProduct: _findProduct,
        Products: _Products,
        showProduct: _showProduct,
        attachProductHover: _attachProductHover,
        productPopupHover: _productPopupHover
    }
})();
MAD.entities = {};
MAD.entities.product = function(ID, Name, BrandName, Href, Image, CommercialMsg, Price, RRP, Save, Rating, Video, OOS, Discount) {
    this.id = ID;
    this.name = Name;
    this.brandName = BrandName;
    this.href = Href;
    this.image = Image;
    this.commercialMsg = CommercialMsg;
    this.price = Price;
    this.rrp = RRP;
    this.save = Save;
    this.rating = Rating;
    this.video = Video;
    this.oos = OOS;
    this.discount = Discount
};
MAD.entities.discount = function(Type, Value, Name, Price, Save, Href) {
    this.type = Type;
    this.value = Value;
    this.name = Name;
    this.price = Price;
    this.save = Save;
    this.href = Href
};
MAD.pages = {};
MAD.pages.all = (function() {
    var _init = function() {
        _flyouts();
        _newsletter();
        _toolbar();
        _searchDropDown();
        _navDelay();
        _carouselTips()
    };
    var _flyouts = function() {
        $("#header ul.preferences li a.expand").click(function(e) {
            e.preventDefault();
            var parentObj = $(this).parent();
            parentObj.find(".ieShim").slideToggle();
            if (parentObj.find(".expandedContent").is(":hidden")) {
                parentObj.find("a.expand").addClass("open");
                parentObj.find(".expandedContent").stop(true, true).slideDown("slow")
            } else {
                parentObj.find(".expandedContent").stop(true, true).slideUp("slow",
                function() {
                    parentObj.find("a.expand").removeClass("open")
                })
            }
            $("ul.preferences li a.expand").not(this).removeClass("open");
            $("ul.preferences li a.expand").not(".open").parent().find(".expandedContent").hide();
            $("ul.preferences li").not(parentObj).find(".ieShim").hide();
            return false
        });
        $("#header ul.preferences li .expandedContent a.closeBox").click(function() {
            var closeObj = $(this).parent();
            closeObj.parent().find(".ieShim").hide();
            closeObj.slideUp("slow",
            function() {
                closeObj.parent().find("a.expand").removeClass("open")
            });
            return false
        })
    };
    var _newsletter = function() {
        $(".newsletterEmail").focus(function() {
            $(this).val("")
        });
        $(".newsletterEmail").blur(function() {
            if ($(this).attr("value") == "") {
                $(this).val("--Enter Email Address--")
            }
        })
    };
    var _toolbar = function() {
        if ($.cookie("ftbState") == "closed") {
            $(".toolbarContainer ul.tbSlide").hide();
            $(".toolbar .tbToggle").addClass("closed")
        }
        $(".toolbarContainer").show();
        $(".toolbar a.expBtn").click(function() {
            var self = $(this).parent().find(".expWrap");
            $(".toolbar .expWrap").not(self).slideUp();
            $(this).parent().find(".expWrap").stop(true, true).slideToggle();
            if ($(this).hasClass("facebook")) {
                var $fb = $('<iframe src="http://www.facebook.com/plugins/likebox.php?id=18727097221&amp;width=402&amp;connections=7&amp;stream=true&amp;header=false&amp;height=480" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:402px; height:480px;" allowTransparency="true"></iframe>');
                $(this).parent().find(".inner .content").html($fb)
            }
            return false
        });
        $(".toolbar .tbToggle").click(function() {
            $(".toolbar ul").animate({
                width: "toggle"
            });
            $(this).toggleClass("closed");
            if ($(this).hasClass("closed")) {
                $.cookie("ftbState", "closed")
            } else {
                $.cookie("ftbState", null)
            }
            return false
        });
        $(".toolbar .expWrap .close").click(function() {
            $(this).parents(".expWrap").slideToggle();
            return false
        });
        if (navigator.platform == "iPad" || navigator.platform == "iPhone" || navigator.platform == "iPod") {
            $(".toolbarContainer").css("position", "static")
        }
    };
    var _searchDropDown = function() {
        $("#searchDropDown .product").live("mouseover mouseout",
        function() {
            $(this).toggleClass("hovered")
        })
    };
    var _impulseCarousel = function() {
        for (i = 1; i <= 2; i++) {
            if ($(".ImpCarousel" + i).length) {
                $(".ImpCarousel" + i + " .impulseCarousel").jCarouselLite({
                    btnNext: ".ImpCarousel" + i + " #next",
                    btnPrev: ".ImpCarousel" + i + " #prev",
                    visible: 1,
                    circular: false
                })
            }
        }
        if ($(".ImpCarousel1").length) {
            $(".ImpCarousel2").hide()
        }
    };
    var _navDelay = function() {
        $(".topLevel > li").hoverIntent({
            sensitivity: 3,
            interval: 200,
            timeout: 0,
            over: function() {
                $(this).addClass("open")
            },
            out: function() {
                $(this).removeClass("open")
            }
        })
    };
    var _carouselTips = function() {
        $(".control").hover(function() {
            if (!$(this).hasClass("disabled")) {
                $(this).find(".carouselTip").stop(false, true).fadeIn(300)
            }
        },
        function() {
            $(this).find(".carouselTip").stop(false, true).fadeOut(300)
        })
    };
    var _IE6 = function() {
        $(window).scroll(function() {
            $(".toolbarContainer").stop().animate({
                top: ($(window).height() + $(document).scrollTop() - 42)
            },
            0, "linear")
        })
    };
    return {
        init: _init,
        navDelay: _navDelay,
        impulseCarousel: _impulseCarousel,
        carouselTips: _carouselTips,
        IE6: _IE6
    }
})();
MAD.pages.home = (function() {
    var _init = function() {
        _saleCarousel()
    };
    var _saleCarousel = function() {
        for (i = 1; i <= 5; i++) {
            if ($(".Carousel" + i).length > 0) {
                $(".Carousel" + i + " .saleItemsCarousel").jCarouselLite({
                    btnNext: ".Carousel" + i + " .next" + i,
                    btnPrev: ".Carousel" + i + " .prev" + i,
                    visible: 1,
                    scroll: 1,
                    circular: false
                })
            }
        }
    };
    return {
        init: _init
    }
})();
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true: false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true: false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true: false;
function ControlVersion() {
    var version;
    var axo;
    var e;
    try {
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version")
    } catch(e) {}
    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
            version = "WIN 6,0,21,0";
            axo.AllowScriptAccess = "always";
            version = axo.GetVariable("$version")
        } catch(e) {}
    }
    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version")
        } catch(e) {}
    }
    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0"
        } catch(e) {}
    }
    if (!version) {
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11"
        } catch(e) {
            version = -1
        }
    }
    return version
}
function GetSwfVer() {
    var flashVer = -1;
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0": "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4]
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1)
            } else {
                if (versionRevision[0] == "r") {
                    versionRevision = versionRevision.substring(1);
                    if (versionRevision.indexOf("d") > 0) {
                        versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"))
                    }
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision
        }
    } else {
        if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) {
            flashVer = 4
        } else {
            if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) {
                flashVer = 3
            } else {
                if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) {
                    flashVer = 2
                } else {
                    if (isIE && isWin && !isOpera) {
                        flashVer = ControlVersion()
                    }
                }
            }
        }
    }
    return flashVer
}
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();
    if (versionStr == -1) {
        return false
    } else {
        if (versionStr != 0) {
            if (isIE && isWin && !isOpera) {
                tempArray = versionStr.split(" ");
                tempString = tempArray[1];
                versionArray = tempString.split(",")
            } else {
                versionArray = versionStr.split(".")
            }
            var versionMajor = versionArray[0];
            var versionMinor = versionArray[1];
            var versionRevision = versionArray[2];
            if (versionMajor > parseFloat(reqMajorVer)) {
                return true
            } else {
                if (versionMajor == parseFloat(reqMajorVer)) {
                    if (versionMinor > parseFloat(reqMinorVer)) {
                        return true
                    } else {
                        if (versionMinor == parseFloat(reqMinorVer)) {
                            if (versionRevision >= parseFloat(reqRevision)) {
                                return true
                            }
                        }
                    }
                }
            }
            return false
        }
    }
}
function AC_AddExtension(src, ext) {
    if (src.indexOf("?") != -1) {
        return src.replace(/\?/, ext + "?")
    } else {
        return src + ext
    }
}
function AC_Generateobj(objAttrs, params, embedAttrs) {
    var str = "";
    if (isIE && isWin && !isOpera) {
        str += "<object ";
        for (var i in objAttrs) {
            str += i + '="' + objAttrs[i] + '" '
        }
        str += ">";
        for (var i in params) {
            str += '<param name="' + i + '" value="' + params[i] + '" /> '
        }
        str += "</object>"
    } else {
        str += "<embed ";
        for (var i in embedAttrs) {
            str += i + '="' + embedAttrs[i] + '" '
        }
        str += "> </embed>"
    }
    document.write(str)
}
function AC_FL_RunContent() {
    var ret = AC_GetArgs(arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs)
}
function AC_SW_RunContent() {
    var ret = AC_GetArgs(arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000", null);
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs)
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
    var ret = new Object();
    ret.embedAttrs = new Object();
    ret.params = new Object();
    ret.objAttrs = new Object();
    for (var i = 0; i < args.length; i = i + 2) {
        var currArg = args[i].toLowerCase();
        switch (currArg) {
        case "classid":
            break;
        case "pluginspage":
            ret.embedAttrs[args[i]] = args[i + 1];
            break;
        case "src":
        case "movie":
            args[i + 1] = AC_AddExtension(args[i + 1], ext);
            ret.embedAttrs["src"] = args[i + 1];
            ret.params[srcParamName] = args[i + 1];
            break;
        case "onafterupdate":
        case "onbeforeupdate":
        case "onblur":
        case "oncellchange":
        case "onclick":
        case "ondblclick":
        case "ondrag":
        case "ondragend":
        case "ondragenter":
        case "ondragleave":
        case "ondragover":
        case "ondrop":
        case "onfinish":
        case "onfocus":
        case "onhelp":
        case "onmousedown":
        case "onmouseup":
        case "onmouseover":
        case "onmousemove":
        case "onmouseout":
        case "onkeypress":
        case "onkeydown":
        case "onkeyup":
        case "onload":
        case "onlosecapture":
        case "onpropertychange":
        case "onreadystatechange":
        case "onrowsdelete":
        case "onrowenter":
        case "onrowexit":
        case "onrowsinserted":
        case "onstart":
        case "onscroll":
        case "onbeforeeditfocus":
        case "onactivate":
        case "onbeforedeactivate":
        case "ondeactivate":
        case "type":
        case "codebase":
        case "id":
            ret.objAttrs[args[i]] = args[i + 1];
            break;
        case "width":
        case "height":
        case "align":
        case "vspace":
        case "hspace":
        case "class":
        case "title":
        case "accesskey":
        case "name":
        case "tabindex":
            ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
            break;
        default:
            ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1]
        }
    }
    ret.objAttrs["classid"] = classid;
    if (mimeType) {
        ret.embedAttrs["type"] = mimeType
    }
    return ret
}; (function($) {
    $.fn.hoverIntent = function(f, g) {
        var cfg = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        cfg = $.extend(cfg, g ? {
            over: f,
            out: g
        }: f);
        var cX, cY, pX, pY;
        var track = function(ev) {
            cX = ev.pageX;
            cY = ev.pageY
        };
        var compare = function(ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) {
                $(ob).unbind("mousemove", track);
                ob.hoverIntent_s = 1;
                return cfg.over.apply(ob, [ev])
            } else {
                pX = cX;
                pY = cY;
                ob.hoverIntent_t = setTimeout(function() {
                    compare(ev, ob)
                },
                cfg.interval)
            }
        };
        var delay = function(ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            ob.hoverIntent_s = 0;
            return cfg.out.apply(ob, [ev])
        };
        var handleHover = function(e) {
            var p = (e.type == "mouseover" ? e.fromElement: e.toElement) || e.relatedTarget;
            while (p && p != this) {
                try {
                    p = p.parentNode
                } catch(e) {
                    p = this
                }
            }
            if (p == this) {
                return false
            }
            var ev = jQuery.extend({},
            e);
            var ob = this;
            if (ob.hoverIntent_t) {
                ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t)
            }
            if (e.type == "mouseover") {
                pX = ev.pageX;
                pY = ev.pageY;
                $(ob).bind("mousemove", track);
                if (ob.hoverIntent_s != 1) {
                    ob.hoverIntent_t = setTimeout(function() {
                        compare(ev, ob)
                    },
                    cfg.interval)
                }
            } else {
                $(ob).unbind("mousemove", track);
                if (ob.hoverIntent_s == 1) {
                    ob.hoverIntent_t = setTimeout(function() {
                        delay(ev, ob)
                    },
                    cfg.timeout)
                }
            }
        };
        return this.mouseover(handleHover).mouseout(handleHover)
    }
})(jQuery); (function(d) {
    var k = d.scrollTo = function(a, i, e) {
        d(window).scrollTo(a, i, e)
    };
    k.defaults = {
        axis: "xy",
        duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1
    };
    k.window = function(a) {
        return d(window)._scrollable()
    };
    d.fn._scrollable = function() {
        return this.map(function() {
            var a = this,
            i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ["iframe", "#document", "html", "body"]) != -1;
            if (!i) {
                return a
            }
            var e = (a.contentWindow || a).document || a.ownerDocument || a;
            return d.browser.safari || e.compatMode == "BackCompat" ? e.body: e.documentElement
        })
    };
    d.fn.scrollTo = function(n, j, b) {
        if (typeof j == "object") {
            b = j;
            j = 0
        }
        if (typeof b == "function") {
            b = {
                onAfter: b
            }
        }
        if (n == "max") {
            n = 9000000000
        }
        b = d.extend({},
        k.defaults, b);
        j = j || b.speed || b.duration;
        b.queue = b.queue && b.axis.length > 1;
        if (b.queue) {
            j /= 2
        }
        b.offset = p(b.offset);
        b.over = p(b.over);
        return this._scrollable().each(function() {
            var q = this,
            r = d(q),
            f = n,
            s,
            g = {},
            u = r.is("html,body");
            switch (typeof f) {
            case "number":
            case "string":
                if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) {
                    f = p(f);
                    break
                }
                f = d(f, this);
            case "object":
                if (f.is || f.style) {
                    s = (f = d(f)).offset()
                }
            }
            d.each(b.axis.split(""),
            function(a, i) {
                var e = i == "x" ? "Left": "Top",
                h = e.toLowerCase(),
                c = "scroll" + e,
                l = q[c],
                m = k.max(q, i);
                if (s) {
                    g[c] = s[h] + (u ? 0 : l - r.offset()[h]);
                    if (b.margin) {
                        g[c] -= parseInt(f.css("margin" + e)) || 0;
                        g[c] -= parseInt(f.css("border" + e + "Width")) || 0
                    }
                    g[c] += b.offset[h] || 0;
                    if (b.over[h]) {
                        g[c] += f[i == "x" ? "width": "height"]() * b.over[h]
                    }
                } else {
                    var o = f[h];
                    g[c] = o.slice && o.slice( - 1) == "%" ? parseFloat(o) / 100 * m: o
                }
                if (/^\d+$/.test(g[c])) {
                    g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m)
                }
                if (!a && b.queue) {
                    if (l != g[c]) {
                        t(b.onAfterFirst)
                    }
                    delete g[c]
                }
            });
            t(b.onAfter);
            function t(a) {
                r.animate(g, j, b.easing, a &&
                function() {
                    a.call(this, n, b)
                })
            }
        }).end()
    };
    k.max = function(a, i) {
        var e = i == "x" ? "Width": "Height",
        h = "scroll" + e;
        if (!d(a).is("html,body")) {
            return a[h] - d(a)[e.toLowerCase()]()
        }
        var c = "client" + e,
        l = a.ownerDocument.documentElement,
        m = a.ownerDocument.body;
        return Math.max(l[h], m[h]) - Math.min(l[c], m[c])
    };
    function p(a) {
        return typeof a == "object" ? a: {
            top: a,
            left: a
        }
    }
})(jQuery);



function RequiredField(sender, args) {
    var val = args.Value;
    if ((val.indexOf("Enter ") != -1 || val == "" || val == "-- Name --") && !Skip(sender)) {
        toggleError(sender, true, "This is a Required Field");
        args.IsValid = false;
        return false
    } else {
        toggleError(sender, false)
    }
    args.IsValid = true;
    return true
}
function RequiredFieldPassword(sender, args) {
    var val = args.Value;
    if ((val.indexOf("Enter ") != -1 || val == "" || val == "-- Name --") && !Skip(sender)) {
        toggleError(sender, true, "This is a Required Field");
        args.IsValid = false;
        return false
    } else {
        if (val.length < 8) {
            toggleError(sender, true, "Password must be at least 8 characters");
            args.IsValid = false;
            return false
        } else {
            toggleError(sender, false)
        }
    }
    args.IsValid = true;
    return true
}
function RequiredFieldShowHidden(sender, args) {
    var val = args.Value;
    if ((val.indexOf("Enter ") != -1 || val == "") && !Skip(sender.id)) {
        toggleError(sender, true, "This is a Required Field");
        var fieldobj = parseFieldName(sender.id, true);
        var obj = $(fieldobj.path + "selectedAddress");
        if (obj != null) {
            if (obj.style != null) {
                obj.style.display = "block"
            }
        }
        args.IsValid = false;
        return false
    } else {
        toggleError(sender, false)
    }
    args.IsValid = true;
    return true
}
function RequiredDropDown(sender, args) {
    var val = args.Value;
    if ((val == -1) && !Skip(sender.id)) {
        toggleError(sender, true, "This is a Required Field");
        args.IsValid = false;
        return false
    } else {
        toggleError(sender, false)
    }
    args.IsValid = true;
    return true
}
function RequiredCheckBox(sender, args) {
    var fieldobj = parseFieldName(sender.id, true);
    var obj = document.getElementById(fieldobj.path + fieldobj.field);
    if ((!obj.checked) && !Skip(sender.id)) {
        toggleError(sender, true, "This is a Required Field");
        args.IsValid = false;
        return false
    } else {
        toggleError(sender, false)
    }
    args.IsValid = true;
    return true
}
function validateDateOfBirth(sender, args) {
    var objRegExp = /(((0[1-9]|[12][0-9]|3[01])([/])(0[13578] | 10 | 12)([/])([1-2][0,9][0-9][0-9]))|(([0][1-9]|[12][0-9]|30)([/])(0[469] | 11)([/])([1-2][0,9][0-9][0-9]))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])([1-2][0,9][0-9][0-9]))|((29)(\.|-|\/)(02)([/])([02468][048] 00)) | ((29)([/])(02)([/])([13579][26] 00)) | ((29)([/])(02)([/])([0 - 9][0 - 9][0][48])) | ((29)([/])(02)([/])([0 - 9][0 - 9][2468][048])) | ((29)([/])(02)([/])([0 - 9][0 - 9][13579][26]))) / ;
    if (args.Value != "" && !Skip()) {
        if (!objRegExp.test(args.Value)) {
            toggleError(sender, true, "Please enter a valid date.");
            args.IsValid = false;
            return false
        } else {
            toggleError(sender, false)
        }
    }
    args.IsValid = true;
    return true
}
function validateEmail(sender, args) {
    var objRegExp = /^[\w\.\-]+@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
    if (args.Value != "" && !Skip()) {
        if (!objRegExp.test(args.Value)) {
            toggleError(sender, true, "Invalid Email Address.");
            args.IsValid = false;
            return false
        } else {
            toggleError(sender, false)
        }
    }
    args.IsValid = true;
    return true
}
function validateCompare(sender, args) {
    var fieldobj = parseFieldName(sender.id, false);
    var compareWith = document.getElementById(fieldobj.path + fieldobj.field);
    if (compareWith) {
        if (compareWith.value != "" && compareWith.value.length > 7) {
            if ((compareWith.value != args.Value) && !Skip()) {
                toggleError(sender, true, "The Fields Do Not Match");
                toggleError(compareWith, true, "The Fields Do Not Match");
                args.IsValid = false;
                return
            } else {
                toggleError(sender, false);
                toggleError(compareWith, false)
            }
        }
    } else {
        args.IsValid = false;
        return
    }
    args.IsValid = true
}
function validateCompareEmail(sender, args) {
    var fieldobj = parseFieldName(sender.id, false);
    var compareWith = document.getElementById(fieldobj.path + fieldobj.field);
    if (compareWith) {
        if (compareWith.value != "") {
            if ((compareWith.value != args.Value) && !Skip()) {
                toggleError(sender, true, "The Fields Do Not Match");
                toggleError(compareWith, true, "The Fields Do Not Match");
                args.IsValid = false;
                return
            } else {
                toggleError(sender, false);
                toggleError(compareWith, false)
            }
        }
    } else {
        args.IsValid = false;
        return
    }
    args.IsValid = true
}
function checkCardNumber(sender, args) {
    if (args.Value != "" && !Skip()) {
        if (!isNumeric(args.Value)) {
            if (! (isNumeric(args.Value.substring(12)) && (args.Value.substring(0, 12) == "xxxxxxxxxxxx"))) {
                toggleError(sender, true, "Invalid Cardnumber");
                args.IsValid = false;
                return false
            }
        } else {
            toggleError(sender, false)
        }
    }
    args.IsValid = true;
    return true
}
function validatePhoneNumber(sender, args) {
    if (args.Value != "" && !Skip()) {
        if (!isNumeric(args.Value)) {
            if (! (isNumeric(args.Value.substring(1)) && (args.Value.substring(0, 1) == "+"))) {
                toggleError(sender, true, "Please enter a valid phone number.");
                args.IsValid = false;
                return false
            }
        } else {
            toggleError(sender, false)
        }
    }
    args.IsValid = true;
    return true
}
function validateNumber(sender, args) {
    if (args.Value != "" && !Skip()) {
        if (!isNumeric(args.Value)) {
            if (! (isNumeric(args.Value.substring(1)) && (args.Value.substring(0, 1) == "+"))) {
                toggleError(sender, true, "Please Enter a Number");
                args.IsValid = false;
                return false
            }
        } else {
            toggleError(sender, false)
        }
    }
    args.IsValid = true;
    return true
}
function isNumeric(sText) {
    var ValidChars = " 0123456789";
    var Char;
    for (i = 0; i < sText.length; i++) {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1) {
            return false
        }
    }
    return true
} (function() {
    var special = jQuery.event.special,
    uid1 = "D" + ( + new Date()),
    uid2 = "D" + ( + new Date() + 1);
    jQuery.event.special.focus = {
        setup: function() {
            var _self = this,
            handler = function(e) {
                e = jQuery.event.fix(e);
                e.type = "focus";
                if (_self === document) {
                    jQuery.event.handle.call(_self, e)
                }
            };
            jQuery(this).data(uid1, handler);
            if (_self === document) {
                if (_self.addEventListener) {
                    _self.addEventListener("focus", handler, true)
                } else {
                    _self.attachEvent("onfocusin", handler)
                }
            } else {
                return false
            }
        },
        teardown: function() {
            var handler = jQuery(this).data(uid1);
            if (this === document) {
                if (this.removeEventListener) {
                    this.removeEventListener("focus", handler, true)
                } else {
                    this.detachEvent("onfocusin", handler)
                }
            }
        }
    };
    jQuery.event.special.blur = {
        setup: function() {
            var _self = this,
            handler = function(e) {
                e = jQuery.event.fix(e);
                e.type = "blur";
                if (_self === document) {
                    jQuery.event.handle.call(_self, e)
                }
            };
            jQuery(this).data(uid2, handler);
            if (_self === document) {
                if (_self.addEventListener) {
                    _self.addEventListener("blur", handler, true)
                } else {
                    _self.attachEvent("onfocusout", handler)
                }
            } else {
                return false
            }
        },
        teardown: function() {
            var handler = jQuery(this).data(uid2);
            if (this === document) {
                if (this.removeEventListener) {
                    this.removeEventListener("blur", handler, true)
                } else {
                    this.detachEvent("onfocusout", handler)
                }
            }
        }
    }
})();
var scrollOffset = 80;
var shown = false;
var useshown = false;
var hideBlockOnError = "";
function toggleError(id, show, txt) {
    if (show) {
        $(id).parent().addClass("fieldError");
        $(id).parent(".fieldError").append("<div class='errorMsg'><table class='err'><tr><td>" + txt + "</td></tr></table></div>");
        $(".fieldError :input").live("focus",
        function() {
            $(this).parent().find(".errorMsg").show()
        }).live("blur",
        function() {
            $(this).parent().find(".errorMsg").hide()
        });
        if (!shown) {
            var input = $(id).parents("fieldset").find(".fieldError :input:first");
            input.focus();
            if (input.parents(".lightbox").length == 0) {
                $.scrollTo(input.offset().top - scrollOffset, {
                    duration: 500
                })
            }
            if (hideBlockOnError.length > 0) {
                if ($(hideBlockOnError)) {
                    $(hideBlockOnError).hide()
                }
            }
            if (useshown) {
                shown = true
            }
        }
        var inputWidth = ($(id).parent().find(":input").width() / 2);
        var inputPos = ($(id).parent().find(":input").position());
        $(id).parent().find(".errorMsg").css({
            left: ((inputPos.left - 60 + inputWidth) + "px"),
            top: ((inputPos.top - 60) + "px")
        })
    } else {
        $(id).parent(".fieldError").find(".errorMsg").remove();
        $(id).parent(".fieldError").removeClass("fieldError")
    }
}
function Skip(id) {
    var skipobj = document.getElementById("SkipValidation");
    var fldobj = document.getElementById(id);
    if (skipobj && fldobj) {
        var ary = skipobj.value.split(",");
        var group = fldobj.getAttribute("CustomGroup");
        if (group != null) {
            for (var i = 0; i < ary.length; i++) {
                if (ary[i] == group) {
                    return true
                }
            }
        }
    }
    return false
}
function toggleSkipGroup(group, leave) {
    var obj = document.getElementById("SkipValidation");
    if (obj) {
        var str = obj.value;
        if (str.indexOf(group) > -1) {
            if (leave != true) {
                str = (str.indexOf("," + group) > -1 ? remove(str, "," + group) : remove(str, group));
                if (str.indexOf(",") == 0) {
                    str = str.substring(1, str.length)
                }
            }
        } else {
            str = str + (str == "" ? group: "," + group)
        }
        obj.value = str
    }
}
function remove(s, t) {
    i = s.indexOf(t);
    r = "";
    if (i == -1) {
        return s
    }
    r += s.substring(0, i) + remove(s.substring(i + t.length), t);
    return r
}
function parseFieldName(id, compare) {
    var path, field;
    if (id.indexOf("val_") != -1) {
        path = id.substring(0, id.indexOf("val_"));
        field = id.substring(id.indexOf("val_") + 4);
        if (!compare) {
            if (field.indexOf("_compare") != -1) {
                field = field.substring(0, field.indexOf("_compare"))
            } else {
                if (field.indexOf("_") != -1) {
                    field = field.substring(0, field.indexOf("_"))
                }
                field = field + "_compare"
            }
        } else {}
        var obj = {
            path: path,
            field: field
        };
        return obj
    }
    return obj
}
function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i];
        if (elm.type == "radio") {
            if (re.test(elm.name)) {
                elm.checked = false
            }
        }
    }
    current.checked = true
}
function validatePostcode(sender, args) {
    if (args.Value != "" && !Skip()) {
        if (!checkPostCode(args.Value)) {
            toggleError(sender, true, "Invalid Postcode");
            args.IsValid = false;
            return false
        } else {
            toggleError(sender, false)
        }
    }
    args.IsValid = true;
    return true
}
function validatePostcodeRemoteError(sender, args) {
    if (args.Value != "" && !Skip()) {
        if (!checkPostCode(args.Value)) {
            toggleRemoteError(errorContainer, textContainer, true);
            args.IsValid = false;
            return false
        } else {
            toggleRemoteError(errorContainer, textContainer, false)
        }
    }
    args.IsValid = true;
    return true
}
function reqValidatePostcode(sender, args) {
    var countryDD = $(sender).parents("fieldset").find("#con_country select");
    var country = countryDD.val();
    switch (country) {
    case "230":
    case "211":
    case "212":
    case "213":
    case "214":
        return validatePostcode(sender, args);
        break;
    default:
        return true;
        break
    }
}
function checkPostCode(toCheck) {
    var alpha1 = "[abcdefghijklmnoprstuwyz]";
    var alpha2 = "[abcdefghklmnopqrstuvwxy]";
    var alpha3 = "[abcdefghjkstuw]";
    var alpha4 = "[abehmnprvwxy]";
    var alpha5 = "[abdefghjlnpqrstuwxyz]";
    var pcexp = new Array();
    pcexp.push(new RegExp("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$", "i"));
    pcexp.push(new RegExp("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$", "i"));
    pcexp.push(new RegExp("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$", "i"));
    pcexp.push(/^(GIR)(\s*)(0AA)$/i);
    pcexp.push(/^(bfpo)(\s*)([0-9]{1,4})$/i);
    pcexp.push(/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);
    var postCode = toCheck;
    var valid = false;
    for (var i = 0; i < pcexp.length; i++) {
        if (pcexp[i].test(postCode)) {
            pcexp[i].exec(postCode);
            postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();
            postCode = postCode.replace(/C\/O\s*/, "c/o ");
            valid = true;
            break
        }
    }
    if (valid) {
        return postCode
    } else {
        return false
    }
};jQuery.cookie = function(name, value, options) {
    if (typeof value != "undefined") {
        options = options || {};
        if (value === null) {
            value = "";
            options.expires = -1
        }
        var expires = "";
        if (options.expires && (typeof options.expires == "number" || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == "number") {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000))
            } else {
                date = options.expires
            }
            expires = "; expires=" + date.toUTCString()
        }
        var path = options.path ? "; path=" + (options.path) : "";
        var domain = options.domain ? "; domain=" + (options.domain) : "";
        var secure = options.secure ? "; secure": "";
        document.cookie = [name, "=", encodeURIComponent(value), expires, path, domain, secure].join("")
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != "") {
            var cookies = document.cookie.split(";");
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + "=")) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break
                }
            }
        }
        return cookieValue
    }
}; 
/*分离了*/
(function($) {
    $.fn.jCarouselLite = function(o) {
        o = $.extend({
            btnPrev: null,
            btnNext: null,
            btnGo: null,
            mouseWheel: false,
            auto: null,
            speed: 200,
            easing: null,
            vertical: false,
            circular: true,
            visible: 3,
            start: 0,
            scroll: 1,
            pagination: false,
            beforeStart: null,
            afterEnd: null
        },
        o || {});
        return this.each(function() {
            var b = false,
            animCss = o.vertical ? "top": "left",
            sizeCss = o.vertical ? "height": "width";
            var c = $(this),
            ul = $("ul", c),
            tLi = $("li", ul),
            tl = tLi.size(),
            v = o.visible;
            if (o.circular) {
                ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone());
                o.start += v
            }
            var f = $("li", ul),
            itemLength = f.size(),
            curr = o.start;
            c.css("visibility", "visible");
            f.css({
                overflow: "hidden",
                float: o.vertical ? "none": "left"
            });
            ul.css({
                margin: "0",
                padding: "0",
                position: "relative",
                "list-style-type": "none",
                "z-index": "1"
            });
            c.css({
                overflow: "hidden",
                position: "relative",
                "z-index": "2",
                left: "0px"
            });
            var g = o.vertical ? height(f) : width(f);
            var h = g * itemLength;
            var j = g * v;
            f.css({
                width: f.width(),
                height: f.height()
            });
            ul.css(sizeCss, h + "px").css(animCss, -(curr * g));
            c.css(sizeCss, j + "px");
            if (o.btnPrev) $(o.btnPrev).click(function() {
                return go(curr - o.scroll)
            });
            if (o.btnNext) $(o.btnNext).click(function() {
                return go(curr + o.scroll)
            });
            if (o.btnGo) $.each(o.btnGo,
            function(i, a) {
                $(a).click(function() {
                    return go(o.circular ? o.visible + i: i)
                })
            });
            if (o.mouseWheel && c.mousewheel) c.mousewheel(function(e, d) {
                return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll)
            });
            if (o.auto) setInterval(function() {
                go(curr + o.scroll)
            },
            o.auto + o.speed);
            function vis() {
                return f.slice(curr).slice(0, v)
            };
            if (! (itemLength <= o.visible)) {
                $(o.btnNext).removeClass("disabled");
            }
            function go(a) {
                if (!b) {
                    if (o.beforeStart) o.beforeStart.call(this, vis());
                    if (o.circular) {
                        if (a <= o.start - v - 1) {
                            ul.css(animCss, -((itemLength - (v * 2)) * g) + "px");
                            curr = a == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll
                        } else if (a >= itemLength - v + 1) {
                            ul.css(animCss, -((v) * g) + "px");
                            curr = a == itemLength - v + 1 ? v + 1 : v + o.scroll
                        } else curr = a
                    } else {
                        if (a < 0 || a > itemLength - v) return;
                        else curr = a
                    }
                    b = true;
                    if (o.pagination == true) {
                        pos = curr;
                        $(".pagination").removeClass("on");
                        $(".pagination#" + (pos)).addClass("on");
                    }
                    ul.animate(animCss == "left" ? {
                        left: -(curr * g)
                    }: {
                        top: -(curr * g)
                    },
                    o.speed, o.easing,
                    function() {
                        if (o.afterEnd) o.afterEnd.call(this, vis());
                        b = false
                    });
                    if (!o.circular) {
                        $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                        $((curr - o.scroll < 0 && o.btnPrev) || (curr + o.scroll > itemLength - v && o.btnNext) || []).addClass("disabled")
                    }
                }
                return false
            }
        })
    };
    function css(a, b) {
        return parseInt($.css(a[0], b)) || 0
    };
    function width(a) {
        return a[0].offsetWidth + css(a, 'marginLeft') + css(a, 'marginRight')
    };
    function height(a) {
        return a[0].offsetHeight + css(a, 'marginTop') + css(a, 'marginBottom')
    }
})(jQuery);
/*分离了*/
(function($) {
    $.fn.MAD_MultiLinkBanner = function() {
        return this.each(function() {
            var $this = $(this);
            var clickArea = ($this.width() / $this.children("a").length);
            $this.children("a").css({
                width: clickArea
            })
        })
    };
    $.fn.MAD_Slideshow = function(o) {
        alert(0);
        o = $.extend({
            paging: true,
            transition: "fade",
            speed: 6000
        },
        o || {});
        return this.each(function() {
            var $this = $(this);
            var slideCount = $this.children("div").length;
            alert(slideCount);
            if (o.paging) {
                var pagingLinks = "";
                for (i = 1; i <= slideCount; i++) {
                    pagingLinks += '<a href="#" title="" rel="' + (i) + '">' + i + "</a>"
                }
                $this.parent().append('<div class="paging">' + pagingLinks + "</div>");
                $this.parent().find(".paging a:first").addClass("active");
                var active = $this.parent().find(".paging a:first");
                var play;
                function fadeImage(clear) {
                    if (clear) {
                        $this.children("div").stop(true, true).fadeOut()
                    }
                    $this.children("div:eq(" + ((active.attr("rel")) - 1) + ")").stop(true, true).fadeIn();
                    play = setInterval(function() {
                        $this.children("div:eq(" + ((active.attr("rel")) - 1) + ")").stop(true, true).fadeOut();
                        active = $this.parent().find(".paging a.active").removeClass("active").next();
                        if (active.length === 0) {
                            active = $this.parent().find(".paging a:first")
                        }
                        active.addClass("active");
                        $this.children("div:eq(" + ((active.attr("rel")) - 1) + ")").stop(true, true).fadeIn()
                    },
                    o.speed)
                }
                $this.parent().find(".paging a").click(function() {
                    active = $(this);
                    $this.parent().find(".paging a").removeClass("active");
                    $(this).addClass("active");
                    clearInterval(play);
                    fadeImage(true);
                    return false
                });
                $this.children("div").hover(function() {
                    clearInterval(play)
                },
                function() {
                    fadeImage(false)
                });
                fadeImage(true)
            } else {
                if (slideCount > 1) {
                    $this.children("div:first-child").show();
                    setInterval(function() {
                        $this.children("div:first-child").fadeOut().next("div").fadeIn().end().appendTo($this)
                    },
                    o.speed)
                } else {
                    $this.children("div").show()
                }
            }
        })
    }
})(jQuery);